'''
Created on Aug 22, 2011

@author: nktran
'''
from xgoogle.search import GoogleSearch, SearchError

def search(query=""):
    """
    """        
    try:
        searcher = GoogleSearch(query)
        for pid in range(5):
            searcher.page = pid
            searcher.results_per_page = 10
            results = searcher.get_results()
            for res in results:
                print res.title.encode('utf8')
                print res.desc.encode('utf8')
                print res.url.encode('utf8')
                print 
    except SearchError, e:
        print "Search failed: %s", e

if __name__ == "__main__":
    search('"as work for"')